package com.bi.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 数据宽表字段实体类
 * 
 * @author BI Platform Team
 * @since 1.0.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_wide_table_field")
public class WideTableField implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 字段ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 宽表ID
     */
    @TableField("wide_table_id")
    private Long wideTableId;

    /**
     * 字段名称
     */
    @TableField("field_name")
    private String fieldName;

    /**
     * 显示名称
     */
    @TableField("display_name")
    private String displayName;

    /**
     * 字段类型
     */
    @TableField("field_type")
    private FieldType fieldType;

    /**
     * 字段长度
     */
    @TableField("field_length")
    private Integer fieldLength;

    /**
     * 精度(数值类型)
     */
    @TableField("precision_scale")
    private String precisionScale;

    /**
     * 是否允许为空
     */
    @TableField("nullable")
    private Boolean nullable;

    /**
     * 默认值
     */
    @TableField("default_value")
    private String defaultValue;

    /**
     * 字段描述
     */
    @TableField("description")
    private String description;

    /**
     * 是否为显示字段
     */
    @TableField("is_display_field")
    private Boolean isDisplayField;

    /**
     * 是否为查询字段
     */
    @TableField("is_query_field")
    private Boolean isQueryField;

    /**
     * 排序序号
     */
    @TableField("sort_order")
    private Integer sortOrder;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 删除标记
     */
    @TableField("deleted")
    @TableLogic
    private Boolean deleted;

    /**
     * 字段类型枚举
     */
    public enum FieldType {
        STRING("字符串"),
        NUMBER("数值"),
        DATE("日期"),
        BOOLEAN("布尔");

        private final String description;

        FieldType(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}